//
//  LCTravelEnrollViewController.m
//  lechuang
//
//  Created by Mr_hi on 2023/6/6.
//  Copyright © 2023 Mooyi. All rights reserved.
//

#import "LCTravelEnrollViewController.h"

#import "LCSetAddressAreaView.h"
#import "LCGlobalService.h"
@interface LCTravelEnrollViewController ()

@property (weak, nonatomic) IBOutlet UITextField *nameTfl;

@property (weak, nonatomic) IBOutlet UITextField *cardNoTfl;

@property (weak, nonatomic) IBOutlet UITextField *phoneTfl;

//@property (weak, nonatomic) IBOutlet UILabel *areaLb;

//@property (strong, nonatomic)NSDictionary * setAreaDic;

@property (weak, nonatomic) IBOutlet UITextField *addressTfl;

@end

@implementation LCTravelEnrollViewController

- (void)viewDidLoad {
    [super viewDidLoad];
}

- (IBAction)backAction:(UIButton *)sender {
    [self.navigationController popViewControllerAnimated:YES];
}

//- (IBAction)setAreaBtnAction:(UIButton *)sender {
//    [self.view endEditing:YES];
//    NSString * province = @"";
//    NSString * city = @"";
//    if (self.setAreaDic[@"province"]) {
//        province = self.setAreaDic[@"province"];
//    }
//    LCSetAddressAreaView * areaView = [[LCSetAddressAreaView alloc] initWithStyle:LCAddressStyleProvinceAndCity Province:province City:city Block:^(NSDictionary *dic) {
//        self.setAreaDic = dic;
//        self.areaLb.text = [NSString stringWithFormat:@"%@%@",dic[@"province"], dic[@"city"]];
//        self.areaLb.textColor = [UIColor colorWithHexString:@"#222222"];
//    }];
//    [areaView show];
//}

- (IBAction)submitBtnAction:(UIButton *)sender {
    if (self.nameTfl.text.length <= 0) {
        [self showErrorText:self.nameTfl.placeholder];
    } else if (self.cardNoTfl.text.length <= 0) {
        [self showErrorText:self.cardNoTfl.placeholder];
    } else if (![NSString isIdCardNumber:self.cardNoTfl.text]) {
        [self showErrorText:@"请输入正确的身份证件号码"];
    } else if (self.phoneTfl.text.length <= 0) {
        [self showErrorText:self.phoneTfl.placeholder];
    } else if (![NSString isMobileNumber:self.phoneTfl.text]) {
        [self showErrorText:@"请输入正确的手机号码"];
    } else if (self.addressTfl.text.length <= 0) {
        [self showText:self.addressTfl.placeholder];
//    } else if ([self.areaLb.text isEqualToString:@"请选择联系人所在城市"]) {
//        [self showErrorText:@"请选择联系人所在城市"];
    } else {
        NSMutableDictionary * param = [NSMutableDictionary dictionary];
        param[@"Clientname"] = self.nameTfl.text;
        param[@"Clientmobile"] = self.phoneTfl.text;
        param[@"ClientID"] = self.cardNoTfl.text;
        param[@"Cityname"] = self.addressTfl.text;
        [LCGlobalService travelEnrollWithTripID:self.tripid Param:param Block:^(BOOL isSuccess) {
            if (isSuccess) {
                [self showSuccessText:@"报名成功"];
                [self.navigationController popToRootViewControllerAnimated:YES];
            }
        }];
    }
}

@end
